package com.qww;

import java.util.Random;

public class Exec07 {

    public static void main(String[] args) {
        Coin coin = new Coin();
        Exec07 t = new Exec07();
        int count = 0;
        System.out.println("=========开始扔硬币============");
        while ( count++ < 10) {
            System.out.print("第" + count +"次: ");
            t.throwCoin(coin);
            coin.show();
        }
    }

    public void throwCoin(Coin coin) {
        Random random = new Random();
        int n = random.nextInt(1000);
        coin.isPositive = n % 2 == 0;
    }
}

class Coin {
    boolean isPositive;

    public void show() {
        if (isPositive) System.out.println("正面");
        else System.out.println("反面");
    }
}
